<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;

class ResetPasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset requests
    | and uses a simple trait to include this behavior. You're free to
    | explore this trait and override any methods you wish to tweak.
    |
    */

    use ResetsPasswords;

    /**
     * Where to redirect users after resetting their password.
     *
     * @var string
     */
    protected $redirectTo = '/';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }


    protected function rules()
    {
        return [
            'phone' => 'required',
            'yzm' =>'required|timeout|yzmgz',
            'password' => 'required|confirmed|min:6',
        ];
    }

    protected function validationErrorMessages()
    {
        return [
            'phone.required'=>'手机号不能为空',
            'yzm.required'=>'验证码不能为空',
            'yzm.timeout'=>'验证码已过期',
            'yzm.yzmgz'=>'验证码不正确',
            'password.required'=>'密码不能为空',
            'password.confirmed'=>'两次密码不一致',
            'password.min'=>'密码最小6位'
        ];
    }

    protected function credentials(Request $request)
    {
        return $request->only(
            'phone', 'password', 'password_confirmation'
        );
    }

    public function username()
    {
        return 'phone';
    }

}
